]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
test-tool: Add --extension option
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 17:56:17 +0000 (18:56 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2025 18:24:01 +0000 (19:24 +0100)
The tool is currently used for running gnome-shell's own tests, but
it could also be used by extensions to automate their testing.

To support that use case, add an --extension option that installs
the provided extension zip and enables the extension before starting
gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3986>

src/gnome-shell-test-tool.in

index c6c31436b343bf4236e48fa36765e98c37ef368d..a16d2be866828cde569ce0aa09840d72b970c925 100755 (executable)
@@ -26,6 +26,17 @@ class GSettingsConfig(ConfigParser):
         with open(f'{dir}/keyfile', 'w') as keyfile:
             self.write(keyfile)
 
+def install_extension(extension, env):
+    self_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
+    args = []
+    args.append(os.path.join(self_dir, 'gnome-extensions'))
+    args.append('install')
+    args.append('--print-uuid')
+    args.append(extension)
+
+    proc = subprocess.run(args, env=env, check=True, capture_output=True, text=True)
+    return proc.stdout.strip()
+
 def show_version(option, opt_str, value, parser):
     print("GNOME Shell Test Tool @VERSION@")
     sys.exit()
@@ -52,6 +63,10 @@ def start_shell(xdg_home, wrap=None, perf_output=None):
     if os.getenv('SHELL_BACKGROUND_IMAGE') is None:
       env['SHELL_BACKGROUND_IMAGE'] = '@pkgdatadir@/perf-background.xml'
 
+    if options.extension:
+        uuid = install_extension(options.extension, env=env)
+        gsettings_config.add('org/gnome/shell', 'enabled-extensions', f'["{uuid}"]')
+
     self_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
     args = []
     if wrap:
@@ -239,6 +254,8 @@ parser.add_argument("--hotplug", action="store_true",
 
 parser.add_argument("--disable-animations", action="store_true",
                     help="Run with animations disabled")
+parser.add_argument("--extension",
+                    help="Run with extension installed and enabled")
 
 options = parser.parse_args()